From 625dddcc44e7d5566acce386b4fbbe35b7e36af3 Mon Sep 17 00:00:00 2001 From: Robert Lipe Date: Sun, 28 Mar 2021 22:54:54 -0500 Subject: [PATCH] Bring back some of the files I nuked and move them to deprecated/ --- make-an1sym.pl => deprecated/make-an1sym.pl | 0 deprecated/naviguide.cc | 423 ++++++++++++++++++++ testo.d/deprecated/alantrl.test | 8 + testo.d/deprecated/alanwpr.test | 8 + testo.d/deprecated/an1.test | 20 + testo.d/deprecated/naviguide.test | 9 + testo.d/deprecated/netstumbler.test | 7 + 7 files changed, 475 insertions(+) rename make-an1sym.pl => deprecated/make-an1sym.pl (100%) create mode 100644 deprecated/naviguide.cc create mode 100644 testo.d/deprecated/alantrl.test create mode 100644 testo.d/deprecated/alanwpr.test create mode 100644 testo.d/deprecated/an1.test create mode 100644 testo.d/deprecated/naviguide.test create mode 100644 testo.d/deprecated/netstumbler.test diff --git a/make-an1sym.pl b/deprecated/make-an1sym.pl similarity index 100% rename from make-an1sym.pl rename to deprecated/make-an1sym.pl diff --git a/deprecated/naviguide.cc b/deprecated/naviguide.cc new file mode 100644 index 000000000..2eebe0bc6 --- /dev/null +++ b/deprecated/naviguide.cc @@ -0,0 +1,423 @@ +/* + Naviguide Routes + + + Copyright (C) 2009 Erez Zuler + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + + */ + +#include "defs.h" +#include "csv_util.h" +#include "jeeps/gpsmath.h" +#include +#include +#include + +#define MYNAME "Naviguide" + + +/************* Specific Naviguide data formats ****************/ + +/* Naviguide file header */ +struct ng_file_header_t { + uint16_t nof_wp; /* Little endean format */ + unsigned char pad1[6]; /* 0xff, 0xff, 0x01, 0x00, 0x06, 0x00 */ + char signature[9]; /* cWaypoint */ + unsigned char pad2[4]; /* 0x01, 0x00, 0x00, 0x00 */ +}; + +/* Naviguide waypoint/rout data */ +struct ng_wp_data_t { + unsigned char pad1[8]; /* 0xfe, 0xff, 0xff, 0xff, 0x01, 0x00, 0x00, 0x00 */ + /* coordination are in old israeli grid */ + int32_t East; + int32_t North; + unsigned char pad2[2]; /* 0x01, 0x01 */ + uint32_t Alt; + char CommentLength; +}; + +struct ng_next_wp_t { + unsigned char pad1[2]; /* 0x01, 0x80 */ + uint16_t next_wp; + unsigned char pad2[2]; /* 0x00, 0x00 */ +}; + +struct ng_wp_no_comment_t { + unsigned char chHeaderLen; + char strName[255]; + ng_wp_data_t wp_data; +}; + + +/* Global variables */ + +static gbfile* file_in, *file_out; +static uint16_t nof_wp; +static route_head* rte_head; +static ng_file_header_t ng_file_header; +static ng_wp_no_comment_t WPNC; +static ng_next_wp_t ng_next_wp; +static char strComment[101]; + +/* Process options */ +/* wp - process only waypoints */ +/* rte - process as route */ +/* wprte - Process waypoints and route */ +static char* process = nullptr; +static char* reorder = nullptr; +static int process_rte = 1; +static int reorder_wp = 0; + +static char temp_short_name[5]; + + + + +/* Forward declarations */ +static void ng_read_file_header(); + +static +QVector ng_args = { + { + "output", &process, "'wp' - Create waypoint file , 'rte' - Create route file", + "rte", ARGTYPE_STRING, ARG_NOMINMAX, nullptr + }, + { + "reorder", &reorder, "'n' - Keep the existing wp name, 'y' - rename waypoints", + "n", ARGTYPE_STRING, ARG_NOMINMAX, nullptr + }, + +}; + +/*===================Utilities ==========================================*/ + +static void +ng_convert_datum(Waypoint* wpt) +{ + double lat, lon; + + auto east = (double) WPNC.wp_data.East; + auto north = (double) WPNC.wp_data.North; + auto alt = (double) WPNC.wp_data.Alt; + + GPS_Math_ICS_EN_To_WGS84(east, north, &lat, &lon); + wpt->latitude = lat; + wpt->longitude = lon; + wpt->altitude = alt; +} + + + +/*=================== File read/write utilities ==========================================*/ + +static void +ng_fwrite_wp_data(const QString& s, const QString& d, ng_wp_data_t* wp_data, gbfile* f) +{ + char z[50]; + + memset(z, 0, 50); + int i = strlen(STRFROMUNICODE(s)); + gbfputc(i, f); + gbfwrite(STRFROMUNICODE(s), 1, i, f); + + gbfwrite(&wp_data->pad1[0], 8, 1, f); + gbfputint32(wp_data->East, f); + gbfputint32(wp_data->North, f); + gbfwrite(&wp_data->pad2[0], 2, 1, f); + gbfputint32(wp_data->Alt, f); + + i = strlen(STRFROMUNICODE(d)); + gbfputc(i, f); + gbfwrite(STRFROMUNICODE(d), 1, i, f); + gbfwrite(z, 44, 1, f); +} + +static void +ng_fwrite_next_wp(ng_next_wp_t* nwp, gbfile* f) +{ + gbfwrite(nwp->pad1, 2, 1, f); + gbfputint16(nwp->next_wp, f); + gbfwrite(nwp->pad2, 2, 1, f); +} + +static void +ng_fread_wp_data(char* d, ng_wp_no_comment_t* wpnc, gbfile* f) +{ + gbfread(&wpnc->chHeaderLen ,sizeof(wpnc->chHeaderLen), 1, f); + gbfread(&wpnc->strName, wpnc->chHeaderLen, 1, f); + wpnc->strName[wpnc->chHeaderLen] = 0; + + + gbfread(&wpnc->wp_data, 8, 1, f); + wpnc->wp_data.East = gbfgetint32(f); + wpnc->wp_data.North = gbfgetint32(f); + gbfread(&wpnc->wp_data.pad2,2, 1, f); + wpnc->wp_data.Alt = gbfgetint32(f); + gbfread(&wpnc->wp_data.CommentLength, 1, 1, f); + int i = (int)wpnc->wp_data.CommentLength; + + + /* Read the comment field */ + gbfread(d, i + 44, 1, f); + +} + +static void +ng_fread_next_wp(ng_next_wp_t* nwp, gbfile* f) +{ + gbfread(&nwp->pad1, 2, 1, f); + nwp->next_wp = gbfgetint16(f); + gbfread(&nwp->pad2, 2, 1, f); +} + +/* =================== Write data functions ====================================*/ + +static void +ng_fill_header_default() +{ + ng_file_header_t default_header = { + 0x00, + {0xff, 0xff, 0x01, 0x00, 0x09, 0x00}, + {'C', 'W', 'a', 'y', 'P', 'o', 'i', 'n', 't'}, + {0x01, 0x00, 0x00, 0x00}, + }; + + ng_file_header =default_header; + +} + + +static void +ng_fill_waypoint_default() +{ + ng_wp_data_t default_wp = { + {0xfe, 0xff, 0xff, 0xff, 0x01, 0x00, 0x00, 0x00}, + 0, + 0, + {0x01, 0x01}, + 0, + 0x00, + + }; + + ng_next_wp_t default_ng_next_wp = { + {0x01, 0x80}, + 0, + {0x00, 0x00}, + }; + + WPNC.wp_data = default_wp; + ng_next_wp = default_ng_next_wp; +} + + +static void +ng_waypt_rd(const Waypoint* wpt) +{ + char z[50]; + double lat, lon; + static int current_wp_ix=0; + + memset(z, 0, 50); + current_wp_ix++; + ng_fill_waypoint_default(); + + if (!GPS_Math_WGS84_To_ICS_EN(wpt->latitude, wpt->longitude, &lon, &lat)) { + fatal(MYNAME ": Waypoint %d is out of the israeli grid area", current_wp_ix); + } + + WPNC.wp_data.North = (int32_t)lat; + WPNC.wp_data.East = (int32_t)lon; + + QString s; + if (reorder_wp) { + sprintf(temp_short_name, "A%03d", current_wp_ix); + s = temp_short_name; + } + + else { + s = wpt->shortname; + } + + ng_fwrite_wp_data(s, wpt->description, &WPNC.wp_data, file_out); + + + /* if not Last WP, write the next one index */ + + if (nof_wp > current_wp_ix) { + ng_next_wp.next_wp = current_wp_ix + 1; + + ng_fwrite_next_wp(&ng_next_wp, file_out); + + } +} + +static void +header_write() +{ + ng_file_header.nof_wp = nof_wp; + gbfputint16(nof_wp, file_out); + gbfwrite(&ng_file_header.pad1[0], 19, 1, file_out); + +} + + +static void +data_write() +{ + nof_wp = waypt_count(); + if (nof_wp) { + header_write(); + waypt_disp_all(ng_waypt_rd); + } else { + nof_wp = route_waypt_count(); + if (nof_wp) { + header_write(); + route_disp_all(nullptr, nullptr, ng_waypt_rd); + } + } +} + + +static void +wr_init(const QString& fname) +{ + file_out = gbfopen_le(fname, "wb", MYNAME); + ng_fill_header_default(); + if (nullptr != reorder) + if (!case_ignore_strcmp(reorder, "y")) { + reorder_wp = 1; + } + +} + +static void +wr_deinit() +{ + gbfclose(file_out); +} + +/*=========================== Read data functions ==================================*/ + +static void +rd_init(const QString& fname) +{ + file_in = gbfopen_le(fname, "rb", MYNAME); + + ng_read_file_header(); + + if (nullptr != process) { + if (!case_ignore_strcmp(process, "wp")) { + process_rte = 0; + } + if (!case_ignore_strcmp(process, "rte")) { + process_rte = 1; + } + } + + +} + +static void +rd_deinit() +{ + gbfclose(file_in); + file_in = nullptr; +} + + + +static void +ng_read_file_header() +{ + + nof_wp = gbfgetint16(file_in); + gbfread(&ng_file_header.pad1[0], 19, 1, file_in); + ng_file_header.nof_wp = nof_wp; + + + if (strncmp("CWayPoint", ng_file_header.signature, 9)) { + fatal("\nInvalid Naviguide file format\n"); + } + + +} + +static void +data_read() +{ + if (process_rte) { + rte_head = route_head_alloc(); + route_add_head(rte_head); + } + + for (int n = 0; n < nof_wp; ++n) { + + auto* wpt_tmp = new Waypoint; + + /* Read waypoint data */ + + ng_fread_wp_data(strComment, &WPNC, file_in); + + + if (n < nof_wp - 1) { + /* + gbfread (&ng_next_wp.pad1[0], 2, 1, file_in); + ng_next_wp.next_wp = gbfgetint16 (file_in); + gbfread (&ng_next_wp.pad2[0], 2, 1, file_in); + */ + ng_fread_next_wp(&ng_next_wp, file_in); + + } + /* Clear commas form the comment for CSV file commonality */ + for (unsigned i = 0; i shortname = STRTOUNICODE(WPNC.strName); + wpt_tmp->description = STRTOUNICODE(strComment); + + if (process_rte) { + route_add_wpt(rte_head, wpt_tmp); + } else { + waypt_add(wpt_tmp); + } + } +} /* data_read */ + + + +ff_vecs_t ng_vecs = { + ff_type_file, + FF_CAP_RW_WPT, + rd_init, + wr_init, + rd_deinit, + wr_deinit, + data_read, + data_write, + nullptr, + &ng_args, + CET_CHARSET_HEBREW, 0 + , NULL_POS_OPS, + nullptr +}; diff --git a/testo.d/deprecated/alantrl.test b/testo.d/deprecated/alantrl.test new file mode 100644 index 000000000..8c655ebe0 --- /dev/null +++ b/testo.d/deprecated/alantrl.test @@ -0,0 +1,8 @@ +# +# Alan Map500 tracklogs< test +# +rm -f ${TMPDIR}/alantrl* +gpsbabel -i alantrl -f ${REFERENCE}/alantrl.trl -o alantrl -F ${TMPDIR}/alantrl-new.trl +gpsbabel -i alantrl -f ${TMPDIR}/alantrl-new.trl -o gpx -F ${TMPDIR}/alantrl-new.gpx +compare ${REFERENCE}/alantrl.gpx ${TMPDIR}/alantrl-new.gpx + diff --git a/testo.d/deprecated/alanwpr.test b/testo.d/deprecated/alanwpr.test new file mode 100644 index 000000000..ccb364f63 --- /dev/null +++ b/testo.d/deprecated/alanwpr.test @@ -0,0 +1,8 @@ +# +# Alan MAp500 waypoint & route test +# +rm -f ${TMPDIR}/alanwpr* +gpsbabel -i alanwpr -f ${REFERENCE}/alanwpr.wpr -o alanwpr -F ${TMPDIR}/alanwpr-new.wpr +gpsbabel -i alanwpr -f ${TMPDIR}/alanwpr-new.wpr -o gpx -F ${TMPDIR}/alanwpr-new.gpx +compare ${REFERENCE}/alanwpr.gpx ${TMPDIR}/alanwpr-new.gpx + diff --git a/testo.d/deprecated/an1.test b/testo.d/deprecated/an1.test new file mode 100644 index 000000000..56a2e167a --- /dev/null +++ b/testo.d/deprecated/an1.test @@ -0,0 +1,20 @@ + +# +# DeLorme .an1 tests +# +rm -f ${TMPDIR}/an1.out +gpsbabel -i an1 -f ${REFERENCE}/foo.an1 -o csv -F ${TMPDIR}/an1.out +compare ${REFERENCE}/an1-in.ref ${TMPDIR}/an1.out + +rm -f ${TMPDIR}/an1.out +gpsbabel -i an1 -f ${REFERENCE}/foo.an1 -o an1 -F ${TMPDIR}/an1.out +bincompare ${TMPDIR}/an1.out ${REFERENCE}/an1-an1.ref + +rm -f ${TMPDIR}/an1.out +gpsbabel -i xmap -f ${REFERENCE}/xmap -o an1 -F ${TMPDIR}/an1.out +bincompare ${TMPDIR}/an1.out ${REFERENCE}/an1-out.ref + +#rm -f ${TMPDIR}/an1.out +#gpsbabel -i gpx -f ${REFERENCE}/an1-in.gpx -o an1 -F ${TMPDIR}/an1.out +#bincompare ${TMPDIR}/an1.out ${REFERENCE}/an1-line-out.ref + diff --git a/testo.d/deprecated/naviguide.test b/testo.d/deprecated/naviguide.test new file mode 100644 index 000000000..da5be625c --- /dev/null +++ b/testo.d/deprecated/naviguide.test @@ -0,0 +1,9 @@ +# +# Naivguide +# +gpsbabel -i naviguide -f ${REFERENCE}/route/naviguide-route.twl -o gpx -F ${TMPDIR}/naviguide.gpx +compare ${REFERENCE}/route/naviguide.gpx ${TMPDIR}/naviguide.gpx +# Make sure ICS negative eastings and northings work. +gpsbabel -i gpx -f ${REFERENCE}/ics.gpx -o naviguide -F ${TMPDIR}/ics.gpx.naviguide +gpsbabel -i naviguide -f ${TMPDIR}/ics.gpx.naviguide -o gpx -F ${TMPDIR}/ics.gpx.naviguide.gpx +compare ${REFERENCE}/ics.gpx.naviguide.gpx ${TMPDIR}/ics.gpx.naviguide.gpx diff --git a/testo.d/deprecated/netstumbler.test b/testo.d/deprecated/netstumbler.test new file mode 100644 index 000000000..bf73c694d --- /dev/null +++ b/testo.d/deprecated/netstumbler.test @@ -0,0 +1,7 @@ +# +# NetStumbler Summary File (read-only) +# +rm -f ${TMPDIR}/netstumbler.mps +gpsbabel -i netstumbler -f ${REFERENCE}/netstumbler.txt -o mapsource -F ${TMPDIR}/netstumbler.mps +bincompare ${TMPDIR}/netstumbler.mps ${REFERENCE}/netstumbler.mps + -- 2.30.2